<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <title>地产管理系统</title>
    <link rel="stylesheet" href="/manage/layui/css/layui.css">
    <link rel="stylesheet" href="/manage/style/admin.css">
    <%--本页css--%>
    <link rel="stylesheet" href="/manage/style/login.css">
    <script src="/manage/js/Plug/vector.js" type="text/javascript" charset="UTF-8"></script>
    <script src="/manage/js/Plug/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/manage/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/manage/js/main.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/cookie.js" type="text/javascript" charset="UTF-8"></script>
    <script src="/js/common-format.js" type="text/javascript" charset="UTF-8"></script>
    <style>
        body{
            position: relative;
        }
        #container {
            position: absolute;
            height: 100%;
            width: 100%;
            left: 0;
            top: 0;
            z-index: 0;
        }
        #output {
            width: 100%;
            height: 100%;
        }
        .layadmin-user-login-main{
            position: relative;
            z-index: 5;
        }
    </style>
</head>
<body>
<div class="layadmin-user-login mylogin" id="LAY-user-login">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>经纪人房产管理系统</h2>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="LAY-user-login-username"></label>
                <input type="text" name="username" value="15826014394" id="LAY-user-login-username" lay-verify="required" placeholder="用户名" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
                <input type="password" name="password" value="123456" id="LAY-user-login-password" lay-verify="required" placeholder="密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="login_submit">登 录</button>
            </div>
        </div>
    </div>
</div>
<div id="container"><div id="output"></div></div>
</body>
<script type="text/javascript">
    layui.use(['form', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
        //监听提交
        form.on('submit(login_submit)', function(data){
            console.log(data)
            var username = $.trim(data.field.username);
            var password = $.trim(data.field.password);
            var param = {
                "username": username,
                "password": password,
            }
            var ii = layer.load(2);
            $.post('/user/login', param, function (value) {
                layer.close(ii);
                if(value.status == "200" || value.status == 200){

                    var listobj = value.obj;

                    setcookie("admin_usercookie", listobj.id); //用户id
                    setcookie("username", listobj.username); //用户名
                    setcookie("realname", listobj.realname); //用户昵称

                    parent.location.href="/index";

                }else {
                    layer.alert("用户名或密码错误!",{icon:2});
                }
            })
        })
        var victor = new Victor("container", "output");
        victor(["#266760", "#057e71"]).set();
    });
</script>
</html>